Download AnalysisDashboard.zip

Interactive Data Visualization

Row

Attrition Count

Attrition

Number of Employee Data Reviewed

1470

Monthly Income

Yes on Attrition

237

No on Attrition

1233

Row

Plotly Bar Plot

Plotly Box Plot of Job Role & Income

Interactive Scatter Plots

Row

Monthly Income v Age

Monthly Income v Time in C. Role

Monthly Income v Time At Company

Row

Comparison of Monthly Income with other variables.

Data Table

Pivot Table - Numeric

Pivot Table - Categorical

About Report





Project By:


Heindel Adu, Stephen Johnson, Ross Fu, Anthony Yeung


Classification: CONFIDENTIAL!

---
title: "Attrition Predictor Analysis"

output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    social: ["github","linkedin", "twitter", "facebook", "menu"]
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(knitr)
library(DT)
library(rpivotTable)
library(ggplot2)
library(plotly)
library(dplyr)
library(openintro)
library(highcharter)
library(ggvis)
library(broom)
```


```{r, message=FALSE}
#"data" has categorical data converted to numerical
# "data2" has a mixed data types
data <- read.csv("~/Documents/Projects/SMU/rProjects/CaseStudy_02/CaseStudy_02/NumData.csv")
data2 <- read.csv("~/Documents/Projects/SMU/rProjects/CaseStudy_02/CaseStudy_02/CaseStudy2-data.csv")
#View(data)
#str(data)
```

```{r echo=FALSE}
# embed all Rmd and csv files
xfun::embed_files(list.files('.', '[.](Rmd|csv)$'))
```

```{r}
mycolors <- c("blue", "#FFC125", "darkgreen", "darkorange", "darkblue")
```

Interactive Data Visualization
=====================================
Row
-------------------------------------
### Attrition Count

```{r}
valueBox(paste("Attrition"),
         color = "darkblue")
#unique.(data$Attrition)

#data %>%
#  summarise(Attrition = n())
```

### Number of Employee Data Reviewed

```{r}

valueBox(length(data$Attrition),
         icon = "fa-users")
```

### **Monthly Income**
```{r}
gauge(round(min(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
      label = "Min Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))
```

```{r}
gauge(round(mean(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
       label = "Avg Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))

```

```{r}
gauge(round(max(data$MonthlyIncome),
            digits = 2),
            min = 0,
            max = 25000,
       label = "Max Monthly Income",
            gaugeSectors(success = c(15000, 25000),
                         warning = c(5000,15000),
                         danger = c(0, 5000),
                         colors = c("green", "yellow", "red")))
```

### Yes on Attrition

```{r, Yes}
valueBox(sum(data$Attrition == "Yes"),
         icon = 'fa-user-o')

```


### No on Attrition

```{r, No}
valueBox(sum(data$Attrition == "No"),
         icon = 'fa-user')
```

Row
-------------------------------------------------
### **Plotly Bar Plot **
```{r}
#summary(data2$Attrition)
#str(data2$Attrition)
#p0 <- ggplot2::data2 %>% sum(JobRole, Attrition) %>%
#  plot_ly(x = ~JobRole, y = ~n, color = ~Attrition)
p1 <- data2 %>%
  group_by(JobRole) %>%
  summarise(count = n()) %>%
  plot_ly(x = ~JobRole,
          y = ~count,
          color = 'blue',
          type = 'bar') %>%
  layout(xaxis = list(title = "Job Role"),
    yaxis = list(title = 'Count'))
p1
#names(data2)
```


### **Plotly Box Plot of Job Role & Income**
```{r}
data2 %>%
         group_by(JobRole) %>%
         plot_ly(y = ~JobRole, x = ~MonthlyIncome, type = "box", boxpoints = "outliers", color = ~JobRole, jitter = 0.3, pointpos = 0, orientation = "h")
```



Interactive Scatter Plots
=====================================
Row
-------------------------------------
### **Monthly Income v Age**
```{r}
j <- loess(MonthlyIncome ~ Age, data = data2)
p2 <- plot_ly(data = data2, x = ~Age,
          y = ~MonthlyIncome,
          color = as.factor(data2$Attrition),
          type = 'scatter', alpha = 0.9) %>%
  add_lines(y= ~fitted(loess(data2$MonthlyIncome ~ data2$Age)),
            line = list(color = 'rgba(7,164,181,1)'),
            name = "Loess Smoother") %>%
  add_ribbons(data = augment(j),
              ymin = ~.fitted - 1.96 * .se.fit,
              ymax = ~.fitted + 1.96 * .se.fit,
              line = list(color = 'rgba(7, 164, 181, 0.05)'),
              fillcolor = 'rgba(7, 164, 181, 0.2)',
              name = "Standard Error") %>%
    layout(xaxis = list(title = "Age"),
    yaxis = list(title = 'Monthly Income'))

p2
```

### **Monthly Income v  Time in C. Role**
```{r}
l <- loess(MonthlyIncome ~ YearsInCurrentRole, data = data2)
p3 <- plot_ly(data = data2, x = ~YearsInCurrentRole,
          y = ~MonthlyIncome,
          color = as.factor(data2$Attrition),
          type = 'scatter', alpha = 0.9) %>%
  add_lines(y= ~fitted(loess(data2$MonthlyIncome ~ data2$YearsInCurrentRole)),
            line = list(color = 'rgba(7,164,181,1)'),
            name = "Loess Smoother") %>%
  add_ribbons(data = augment(l),
              ymin = ~.fitted - 1.96 * .se.fit,
              ymax = ~.fitted + 1.96 * .se.fit,
              line = list(color = 'rgba(7, 164, 181, 0.05)'),
              fillcolor = 'rgba(7, 164, 181, 0.2)',
              name = "Standard Error") %>%
    layout(xaxis = list(title = "Years In Current Role"),
    yaxis = list(title = 'Monthly Income'))

p3
```

### **Monthly Income v Time At Company **
```{r}
k <- loess(MonthlyIncome ~ YearsAtCompany, data = data2)
p5 <- plot_ly(data = data2, x = ~YearsAtCompany,
          y = ~MonthlyIncome,
          color = as.factor(data2$Attrition),
          type = 'scatter', alpha = 0.9) %>%
  add_lines(y= ~fitted(loess(data2$MonthlyIncome ~ data2$YearsAtCompany)),
            line = list(color = 'rgba(7,164,181,1)'),
            name = "Loess Smoother") %>%
  add_ribbons(data = augment(k),
              ymin = ~.fitted - 1.96 * .se.fit,
              ymax = ~.fitted + 1.96 * .se.fit,
              line = list(color = 'rgba(7, 164, 181, 0.05)'),
              fillcolor = 'rgba(7, 164, 181, 0.2)',
              name = "Standard Error") %>%
    layout(xaxis = list(title = "Years At Company"),
    yaxis = list(title = 'Monthly Income'))

p5
```

Row
---------------------------------------------

Comparison of Monthly Income with other variables.

```{r} ### **Box Plot of Top State** #data2 %>% # group_by(JobRole) %>% # ggvis(~JobRole, ~MonthlyIncome, fill = ~JobRole) %>% # layer_boxplots() ``` Data Table ======================================== ```{r} datatable(data2, caption = "Attrition Data", rownames = TRUE, filter = "top", options = list(pageLength = 25)) ``` Pivot Table - Numeric ========================================= ```{r} rpivotTable(data, aggregatorName = "Count", cols= "Attrition", rows = "JobRole", rendererName = "Heatmap") ``` Pivot Table - Categorical ========================================= ```{r} rpivotTable(data2, aggregatorName = "Count", cols= "Attrition", rows = "JobRole", rendererName = "Heatmap") ``` About Report ========================================



Project By:


Heindel Adu, Stephen Johnson, Ross Fu, Anthony Yeung


Classification: CONFIDENTIAL!